#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <math.h>

/*Test fullDeckCount. This function checks */
int main(){

  struct gameState state;
  int i;
  int j;
  int n;
  int ret;
  int fail = 0;
  int card;
  int cardCount;

  SelectStream(2);
  PutSeed(3);


  printf("Testing fullDeckCount\n");
  for (n = 0; n < 2000; n++) {

    //Choose card to count
    card = floor(Random()*25);

    //For each player
    for(j=0; j<4; j++){
      //Fill ten cards in each pile
      for (i = 0; i < 10; i++) {
        state.deck[j][i] = floor(Random()*25);
        if(state.deck[j][i] == card){
          cardCount++;
        }
        state.hand[j][i] = floor(Random()*25);
        if(state.hand[j][i] == card){
          cardCount++;
        }
        state.discard[j][i] = floor(Random()*25);
        if(state.discard[j][i] == card){
          cardCount++;
        }


        }
        state.deckCount[j] = 10;
        state.handCount[j] = 10;
        state.discardCount[j] = 10;

        ret = fullDeckCount(j, card, &state);

        if(ret != cardCount){
          printf("Test FAILED \n");
          fail++;
        }else{
          printf("Test PASSED\n");
      }
      //Reset test variables
      cardCount = 0;

    }

    printf("This is test %d\n", n);
    //Reset test variables
    cardCount = 0;
  }

  printf("fullDeckCount Summary: %d tests failed.\n", fail);


return(0);

}
